package cn.gson.fengboot.model.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Objects;

@Entity
public class Zcontract {
    private int conId;//ID
    private Dbusiness busId;//商机ID
    private TfyclientForm clientId;//客户ID
    private String conNo;//合同编号
    private String conTheme;//主题
    private BigDecimal conTotal;//总金额
    private BigDecimal conGross;//合同毛利
    private String conSignatory;//客户签约人
    private String mySignatory;//我方签约人
    private Timestamp conTime;//签约时间
    private Timestamp conDeadline;//最终期限
    private String conAccessory;//正文及附件
    private String conRemark;//备注
    private String conPeople;//负责人
    private int conZt;//状态
    private Collection<Zcontractdetails> zcontractdetailsByConId;
    private Collection<Zorder> zordersByConId;

    @Id
    @Column(name = "con_id")
    @GeneratedValue(strategy= GenerationType.IDENTITY)   //自增长
    public int getConId() {
        return conId;
    }

    public void setConId(int conId) {
        this.conId = conId;
    }

    @ManyToOne
    @JoinColumn(name = "bus_id", referencedColumnName = "bus_id")
    public Dbusiness getBusId() {
        return busId;
    }

    public void setBusId(Dbusiness busId) {
        this.busId = busId;
    }

    @ManyToOne
    @JoinColumn(name = "client_id", referencedColumnName = "client_id")
    public TfyclientForm getClientId() {
        return clientId;
    }

    public void setClientId(TfyclientForm clientId) {
        this.clientId = clientId;
    }

    @Basic
    @Column(name = "con_deadline")
    public Timestamp getConDeadline() {
        return conDeadline;
    }

    public void setConDeadline(Timestamp conDeadline) {
        this.conDeadline = conDeadline;
    }

    @Basic
    @Column(name = "con_no")
    public String getConNo() {
        return conNo;
    }

    public void setConNo(String conNo) {
        this.conNo = conNo;
    }

    @Basic
    @Column(name = "con_zt")
    public int getConZt() {
        return conZt;
    }

    @Basic
    @Column(name = "con_gross")
    public BigDecimal getConGross() {
        return conGross;
    }

    public void setConGross(BigDecimal conGross) {
        this.conGross = conGross;
    }

    public void setConZt(int conZt) {
        this.conZt = conZt;
    }

    @Basic
    @Column(name = "con_theme")
    public String getConTheme() {
        return conTheme;
    }

    public void setConTheme(String conTheme) {
        this.conTheme = conTheme;
    }

    @Basic
    @Column(name = "con_total")
    public BigDecimal getConTotal() {
        return conTotal;
    }

    public void setConTotal(BigDecimal conTotal) {
        this.conTotal = conTotal;
    }


    @Basic
    @Column(name = "con_signatory")
    public String getConSignatory() {
        return conSignatory;
    }

    public void setConSignatory(String conSignatory) {
        this.conSignatory = conSignatory;
    }

    @Basic
    @Column(name = "my_signatory")
    public String getMySignatory() {
        return mySignatory;
    }

    public void setMySignatory(String mySignatory) {
        this.mySignatory = mySignatory;
    }

    @Basic
    @Column(name = "con_time")
    public Timestamp getConTime() {
        return conTime;
    }

    public void setConTime(Timestamp conTime) {
        this.conTime = conTime;
    }


    @Basic
    @Column(name = "con_accessory")
    public String getConAccessory() {
        return conAccessory;
    }

    public void setConAccessory(String conAccessory) {
        this.conAccessory = conAccessory;
    }

    @Basic
    @Column(name = "con_remark")
    public String getConRemark() {
        return conRemark;
    }

    public void setConRemark(String conRemark) {
        this.conRemark = conRemark;
    }

    @Basic
    @Column(name = "con_people")
    public String getConPeople() {
        return conPeople;
    }

    public void setConPeople(String conPeople) {
        this.conPeople = conPeople;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Zcontract zcontract = (Zcontract) o;
        return conId == zcontract.conId &&
                Objects.equals(busId, zcontract.busId) &&
                Objects.equals(clientId, zcontract.clientId) &&
                Objects.equals(conNo, zcontract.conNo) &&
                Objects.equals(conTheme, zcontract.conTheme) &&
                Objects.equals(conTotal, zcontract.conTotal) &&
                Objects.equals(conSignatory, zcontract.conSignatory) &&
                Objects.equals(mySignatory, zcontract.mySignatory) &&
                Objects.equals(conTime, zcontract.conTime) &&
                Objects.equals(conAccessory, zcontract.conAccessory) &&
                Objects.equals(conRemark, zcontract.conRemark) &&
                Objects.equals(conPeople, zcontract.conPeople);
    }

    @Override
    public int hashCode() {
        return Objects.hash(conId, busId, clientId, conNo, conTheme, conTotal, conSignatory, mySignatory, conTime, conAccessory, conRemark, conPeople);
    }



    @OneToMany(mappedBy = "conId")
    public Collection<Zcontractdetails> getZcontractdetailsByConId() {
        return zcontractdetailsByConId;
    }

    public void setZcontractdetailsByConId(Collection<Zcontractdetails> zcontractdetailsByConId) {
        this.   zcontractdetailsByConId = zcontractdetailsByConId;
    }

    @OneToMany(mappedBy = "conId")
    public Collection<Zorder> getZordersByConId() {
        return zordersByConId;
    }

    public void setZordersByConId(Collection<Zorder> zordersByConId) {
        this.zordersByConId = zordersByConId;
    }

    @Override
    public String toString() {
        return "Zcontract{" +
                "conId=" + conId +
                ", busId=" + busId +
                ", clientId=" + clientId +
                ", conNo='" + conNo + '\'' +
                ", conTheme='" + conTheme + '\'' +
                ", conTotal=" + conTotal +
                ", conGross=" + conGross +
                ", conSignatory='" + conSignatory + '\'' +
                ", mySignatory='" + mySignatory + '\'' +
                ", conTime=" + conTime +
                ", conAccessory='" + conAccessory + '\'' +
                ", conRemark='" + conRemark + '\'' +
                ", conPeople='" + conPeople + '\'' +
                ", conZt=" + conZt +
                ", zcontractdetailsByConId=" + zcontractdetailsByConId +
                ", zordersByConId=" + zordersByConId +
                '}';
    }
}
